/*
 * @lc app=leetcode.cn id=2144 lang=typescript
 *
 * [2144] 打折购买糖果的最小开销
 */

// @lc code=start
function minimumCost(cost: number[]): number {
    cost.sort((a, b) => b - a);

    return cost
        .filter((_, index) => (index + 1) % 3)
        .reduce((a, b) => a + b, 0);
}
// @lc code=end
